package com.yonyou.crm.sys.quartz.quartztask;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.yonyou.crm.bpub.approval.service.ProcessBizServiceImpl;
import com.yonyou.crm.sys.quartz.common.ContextUtil;
import com.yonyou.iuap.context.InvocationInfoProxy;
import com.yonyou.iuap.dispatch.ITask;

@Service
public class ApprovalSyn implements ITask{
	@SuppressWarnings("unused")
	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	ProcessBizServiceImpl processService;
	
	@Override
	public void execute(Map<String, Object> paramMap) {
		String tentantid = JSON.parseObject((String)paramMap.get("data")).getString("tentantid");
		logger.debug((String)paramMap.get("data"));
		InvocationInfoProxy.setTenantid(tentantid);
		getProcessBizService().synDeptsAndUsers();
	}
	private ProcessBizServiceImpl getProcessBizService() {
		return (ProcessBizServiceImpl) ContextUtil
				.getBean("ProcessBizServiceImpl");
	}
}
